//
// Created by 21126 on 2023/5/19.
//

#ifndef CLION_TEST_U2_E1_H
#define CLION_TEST_U2_E1_H

#include "U2_i2c.h"

#define LED_R 0
#define LED_G 1
#define LED_B 2

#define LED0_ON_L 0x6       // LED0 control address
#define LED0_ON_H 0x7
#define LED0_OFF_L 0x8
#define LED0_OFF_H 0x9

#define PCA9685_MODE1 0x0   // PCA9685 mode setting

#define ALLLED_ON_L 0xFA    // all LED control address
#define ALLLED_ON_H 0xFB
#define ALLLED_OFF_L 0xFC
#define ALLLED_OFF_H 0xFD

#define	SYSTEM_ON_E1			0x21
#define TUBE_ON					0x81
#define TUBE_OFF				0x80
#define ROW_OUTPUT				0xA0

// E1 address struct
typedef struct{
    i2c_addr_def rgb_addr[4];
    i2c_addr_def tube_addr[4];
} e1_addr_def;

void u2_setPWM(int fd, unsigned char slave_address, unsigned char num, __u16 on, __u16 off);//Set signal PWM
void u2_setPWM_off(int fd, unsigned char slave_address);
i2c_addr_def u2_e1_led_init(int fd);
i2c_addr_def u2_e1_tube_init(int fd);
void u2_pca9685_init(int fd, unsigned char slave_address);
void u2_ht16k33_init(int fd, unsigned char slave_address);
void u2_ht16k33_RAM_init(int fd, unsigned char slave_address);
void u2_display_tube(__u16 value, i2c_addr_def e1_tube_addr);
#endif //CLION_TEST_U2_E1_H
